'''第一版
money = 1000  # 初始金币
# 初始化商品列表和价格
products = {"黑神话悟空": 599, "艾尔登法环": 299, "双人成行": 199}
shopping_cart = []  # 初始化购物车为空
while True:
    print(f"欢迎来到游戏小店，您当前拥有金额：{money},当前游戏商品有:", ",".join(products.keys()))
    product_name = input("请输入您想要购买的商品(输入Q或者q退出)：")
    if product_name.upper() == 'Q':
        break
    if product_name in products:
            product_price = products[product_name]
            if product_price <= money:
                shopping_cart.append(product_name)
                money -= product_price
                print(f"恭喜，购买成功！您当前剩余{money:.2f}")
            else:
                print('穷鬼，钱不够，请到其他超市购买')
    else:
            print("没有这个商品，别瞎弄！")
if shopping_cart:
    print("购物小票：")
    for item in shopping_cart:
        print(item)
else:
    print("您的购物车为空。")
'''



'''
import random
from datetime import datetime
money = 1000  # 初始金币
# 初始化商品列表和价格
products = {"黑神话悟空": 599, "艾尔登法环": 299, "双人成行": 199}
shopping_cart = []  # 初始化购物车为空
#设置购物券列表
coupons = [
    {"product":"黑神话悟空","discount": 0.95},
    {"product":"黑神话悟空","discount": 0.90},
    {"product":"黑神话悟空","discount": 0.85},
    {"product":"黑神话悟空","discount": 0.80},
    {"product":"艾尔登法环","discount": 0.95},
    {"product":"艾尔登法环","discount": 0.90},
    {"product":"艾尔登法环","discount": 0.85},
    {"product":"双人成行","discount": 0.95},
    {"product": "双人成行", "discount": 0.90},
    {"product": "双人成行", "discount": 0.85},
]
# 随机抽取一张优惠券
coupon = random.choice(coupons)
print(f"恭喜您抽到了 {coupon['product']} 的 {coupon['discount'] * 10} 折优惠券！")

while True:
    print(f"您当前拥有金额：{money:.2f},当前可购买的商品有:", ", ".join(products.keys()))
    action = input("请输入您想要购买的商品名称（输入 Q 或 q 退出，输入 T 或 t 退货）: ")
    if action.upper() == 'Q':
        break
    elif action.upper() == 'T':
        if not shopping_cart:
            print("您的购物车为空，无法退货。")
            continue
        print("您的购物车中有:", ", ".join(shopping_cart))
        return_product = input("请输入要退货的商品名称: ")
        if return_product in shopping_cart:
            product_price = products[return_product]
            if coupon["product"] == return_product:
                product_price *= coupon["discount"]
            money += product_price
            shopping_cart.remove(return_product)
            print(f"退货成功！您的卡余额还剩{money:.2f}")
        else:
            print("您的购物车中没有该商品，无法退货。")
    elif action in products:
        product_price = products[action]
        if coupon["product"] == action:
            product_price *= coupon["discount"]
        if money >= product_price:
            shopping_cart.append(action)
            money -= product_price
            print(f"恭喜，购买成功！您的卡余额还剩{money:.2f}")
        else:
            print("穷鬼，钱不够！请到其他超市购买！")
    else:
        print("没有这个商品，别瞎弄！")
# 计算购买总商品的价值
total_value = 0
for item in shopping_cart:
    price = products[item]
    if coupon["product"] == item:
        price *= coupon["discount"]
    total_value += price

# 打印购物小条
if shopping_cart:
    shopping_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print("-" * 30)
    print("购物小条")
    print(f"购物时间: {shopping_time}")
    print(f"卡余额: {money:.2f}")
    print(f"购物数量: {len(shopping_cart)}")
    print(f"购买总商品的价值: {total_value:.2f}")
    print("商品明细:")
    for item in shopping_cart:
        price = products[item]
        if coupon["product"] == item:
            price *= coupon["discount"]
        print(f"{item}: {price:.2f}")
    print("-" * 30)
else:
    print("您的购物车为空。")
'''